package io.write_file;

import java.io.*;

/**
 * @author haomin
 * @date 2022/05/09 20:26
 **/
public class WriteTest {
    public static void main(String[] args) throws IOException {
        try (OutputStream os = new FileOutputStream("D:\\电影\\文件操作\\write2.txt")){
            try (Writer writer = new OutputStreamWriter(os,"UTF-8")){
                try (PrintWriter printWriter = new PrintWriter(writer)){
                    printWriter.println("你好世界！");
                    printWriter.print("中国");
                    printWriter.printf("%s %d\r\n","加油",666);
                    printWriter.flush();
                }
            }
        }

        try(OutputStream os = new FileOutputStream("src/io/read_file/hello.txt")){
            try(Writer writer = new OutputStreamWriter(os, "utf-8")){
                try(PrintWriter printWriter = new PrintWriter(writer)){
                    printWriter.println("ssss");
                    printWriter.print("aa");
                    printWriter.println("bb");
                    printWriter.println("cccc");
                    printWriter.flush();
                }
            }
        }
    }
}